const { contextBridge, ipcRenderer } = require('electron')

// 暴露安全的 API 给渲染进程
contextBridge.exposeInMainWorld('electronAPI', {
  // 窗口控制
  minimizeToTray: () => ipcRenderer.send('minimize-to-tray'),
  closeWindow: () => ipcRenderer.send('close-window'),
  toggleAlwaysOnTop: () => ipcRenderer.send('toggle-always-on-top'),
  
  // 窗口拖动
  startDrag: () => ipcRenderer.send('window-move-start'),
  drag: () => ipcRenderer.send('window-moving'),
  
  // 窗口大小调整
  resizeWindow: (width, height) => ipcRenderer.send('resize-window', { width, height }),
  
  // 接收主进程消息
  onAlwaysOnTopChanged: (callback) => {
    ipcRenderer.on('always-on-top-changed', (event, value) => callback(value))
  },
  
  // 环境信息
  isElectron: true,
  platform: process.platform
})

